/*
 ------------------------------------------------------------------------------
 Copyright (C) 2006-2007 Team Blur.

 This file is part of the Quantum Engine source code.

 The Quantum Engine source code is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or (at your
 option) any later version.

 The Quantum Engine source code is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 more details.

 You should have received a copy of the GNU General Public License along with
 the Quantum Engine source code; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 ------------------------------------------------------------------------------
*/


#ifndef __SG_DICT_H__
#define __SG_DICT_H__


#define KEY_VALUES_HASH_SIZE		16

typedef struct keyValue_s {
	const char *			key;
	const char *			value;

	struct keyValue_s *		next;
	struct keyValue_s *		nextHash;
} keyValue_t;

class odDict {
private:
	keyValue_t *			keyValuesHashTable[KEY_VALUES_HASH_SIZE];
	keyValue_t *			keyValues;

public:
							odDict (void);
							~odDict (void);

	void					Write (fileHandle_t f) const;

	bool					Parse (script_t *script);

	void					ListKeyValues (void) const;

	const keyValue_t *		FindKeyValue (const char *key) const;
	keyValue_t *			FindKeyValue (const char *key);

	void					AddKeyValue (const char *key, const char *value);
	void					RemoveKeyValue (const char *key);

	bool					GetString (const char *key, const char **value, const char *defaultValue = "") const;
	bool					GetBool (const char *key, bool *value, const char *defaultValue = "0") const;
	bool					GetInteger (const char *key, int *value, const char *defaultValue = "0") const;
	bool					GetFloat (const char *key, float *value, const char *defaultValue = "0") const;
	bool					GetVec2 (const char *key, odVec2 &value, const char *defaultValue = "0 0") const;
	bool					GetVec3 (const char *key, odVec3 &value, const char *defaultValue = "0 0 0") const;
	bool					GetVec4 (const char *key, odVec4 &value, const char *defaultValue = "0 0 0 0") const;
	bool					GetVec5 (const char *key, odVec5 &value, const char *defaultValue = "0 0 0 0 0") const;
	bool					GetAngles (const char *key, odAngles &value, const char *defaultValue = "0 0 0") const;
	bool					GetQuat (const char *key, odQuat &value, const char *defaultValue = "0 0 0 1") const;
	bool					GetMat3 (const char *key, odMat3 &value, const char *defaultValue = "1 0 0 0 1 0 0 0 1") const;
	bool					GetMat4 (const char *key, odMat4 &value, const char *defaultValue = "1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1") const;

	void					SetString (const char *key, const char *value);
	void					SetBool (const char *key, bool value);
	void					SetInteger (const char *key, int value);
	void					SetFloat (const char *key, float value);
	void					SetVec2 (const char *key, const odVec2 &value);
	void					SetVec3 (const char *key, const odVec3 &value);
	void					SetVec4 (const char *key, const odVec4 &value);
	void					SetVec5 (const char *key, const odVec5 &value);
	void					SetAngles (const char *key, const odAngles &value);
	void					SetQuat (const char *key, const odQuat &value);
	void					SetMat3 (const char *key, const odMat3 &value);
	void					SetMat4 (const char *key, const odMat4 &value);
};


#endif	// __SG_DICT_H__
